package com.example.toutiao.view

import android.os.Bundle
import android.view.View
import androidx.recyclerview.widget.GridLayoutManager
import com.example.toutiao.R
import com.example.toutiao.ui.main.adpater.ChannelAdapter
import com.example.toutiao.ui.main.model.TabListModel
import kotlinx.android.synthetic.main.dialog_channel.view.*

class ChannelDialog(data: TabListModel): BaseDialogFragment() {
    private var data:TabListModel=data
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setStyle(STYLE_NO_TITLE,R.style.Dialog)

    }
    override fun initData() {


    }

    override fun initView(view: View) {
        dialog!!.window!!.setWindowAnimations(R.style.dialogAnim)
        /*透明背景*/
//        StatusBarUtils.setTranslateStatus(dialog!!)
        view.iv_close.setOnClickListener {
            dismiss()
        }
        val layoutManager=GridLayoutManager(dialog!!.context,4)
        view.rv_tab_list.layoutManager=layoutManager
        val adapter=ChannelAdapter(data)
        layoutManager.spanSizeLookup=object:GridLayoutManager.SpanSizeLookup(){
            override fun getSpanSize(position: Int): Int {
                return when(adapter.getItemViewType(position)){
                    0->4
                    1->4
                    2->1
                    else->1
                }
            }
        }
        view.rv_tab_list.adapter= adapter
    }

    override fun getLayout(): Int = R.layout.dialog_channel
}